package sk.isomi.minihr.mssql;

import java.sql.DriverManager;
import java.sql.SQLException;

public class SQLReader_SqlJdbc extends SQLReader {
	public static final String urlPrefix = "jdbc:sqlserver://";
	
	public SQLReader_SqlJdbc(String server, int port, String instanceName, String database, String user, String password) {
		super(server, port, instanceName, database, user, password);
	}
	
	public boolean connect() {
		boolean success = false;

		String urlSQL = String.format("%s%s:%d;databaseName=%s;user=%s;password=%s;", urlPrefix, server, port, database, user, password);

		try {
			conSQL = DriverManager.getConnection(urlSQL);
			success = true;
		} catch (SQLException e) {
			conSQL = null;
			e.printStackTrace();
		}

		return success;
	}
}